using UnityEngine;

public struct MuscleJointLimits
{
	private HingeJoint2D joint;

	private JointAngleLimits2D limits;

	private JointAngleLimits2D newLimits;

	public MuscleJointLimits(HingeJoint2D hingleJoint)
	{
		joint = hingleJoint;
		limits = default(JointAngleLimits2D);
		limits.min = Mathf.Min(hingleJoint.limits.min, hingleJoint.limits.max);
		limits.max = Mathf.Max(hingleJoint.limits.min, hingleJoint.limits.max);
		newLimits = default(JointAngleLimits2D);
		Vector3 eulerAngles = hingleJoint.gameObject.transform.eulerAngles;
		float z = eulerAngles.z;
		Vector3 eulerAngles2 = hingleJoint.connectedBody.transform.eulerAngles;
		float num = Mathf.DeltaAngle(z, eulerAngles2.z);
		if (limits.min <= num && num <= limits.max)
		{
			newLimits.min = num;
			newLimits.max = num + 1f;
			joint.limits = newLimits;
		}
	}

	public void ResetLimits()
	{
		if (joint != null)
		{
			joint.limits = limits;
		}
	}
}
